<template>
  <view class="order-result">
    <!-- 结果状态 -->
    <view class="result-status">
      <image v-if="status === 'success'" src="/static/success.png" mode="aspectFit"></image>
      <image v-else src="/static/fail.png" mode="aspectFit"></image>
      <text class="status-text">{{statusText}}</text>
      <text class="status-desc">{{statusDesc}}</text>
    </view>
    
    <!-- 订单信息 -->
    <view class="order-info">
      <view class="info-item">
        <text>订单编号</text>
        <text>{{orderInfo.orderId}}</text>
      </view>
      <view class="info-item">
        <text>支付金额</text>
        <text class="price">¥{{orderInfo.amount}}</text>
      </view>
      <view class="info-item">
        <text>支付方式</text>
        <text>{{orderInfo.paymentType}}</text>
      </view>
      <view class="info-item">
        <text>下单时间</text>
        <text>{{orderInfo.createTime}}</text>
      </view>
    </view>
    
    <!-- 操作按钮 -->
    <view class="action-btns">
      <button class="btn" @click="goHome">返回首页</button>
      <button class="btn primary" @click="goOrderDetail">查看订单</button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      status: 'success',
      orderInfo: {
        orderId: '1234567890',
        amount: '109.00',
        paymentType: '微信支付',
        createTime: '2023-05-20 14:30:25'
      }
    }
  },
  computed: {
    statusText() {
      return this.status === 'success' ? '支付成功' : '支付失败'
    },
    statusDesc() {
      return this.status === 'success' 
        ? '订单已支付成功，我们将尽快为您发货' 
        : '订单支付失败，请重新尝试支付'
    }
  },
  onLoad(options) {
    if (options.status) {
      this.status = options.status
    }
    if (options.order_id) {
      this.orderInfo.orderId = options.order_id
    }
    // 模拟获取订单信息
    this.getOrderInfo()
  },
  methods: {
    getOrderInfo() {
      // 实际项目中这里应该请求API获取订单详情
      // 这里使用模拟数据
    },
    goHome() {
      uni.switchTab({
        url: '/pages/index/index'
      })
    },
    goOrderDetail() {
      uni.navigateTo({
        url: '/pages/order/detail?id=' + this.orderInfo.orderId
      })
    }
  }
}
</script>

<style>
.order-result {
  padding: 40rpx;
}
.result-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60rpx 0;
}
.result-status image {
  width: 120rpx;
  height: 120rpx;
  margin-bottom: 20rpx;
}
.status-text {
  font-size: 36rpx;
  color: #333;
  font-weight: bold;
  margin-bottom: 10rpx;
}
.status-desc {
  font-size: 28rpx;
  color: #999;
}
.order-info {
  margin-top: 40rpx;
  background-color: #fff;
  border-radius: 10rpx;
  padding: 30rpx;
}
.info-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 25rpx;
  font-size: 28rpx;
  color: #666;
}
.info-item:last-child {
  margin-bottom: 0;
}
.price {
  color: #ff2d4a;
  font-weight: bold;
}
.action-btns {
  display: flex;
  margin-top: 60rpx;
}
.btn {
  flex: 1;
  height: 80rpx;
  line-height: 80rpx;
  text-align: center;
  font-size: 28rpx;
  color: #666;
  background-color: #fff;
  border: 1rpx solid #ddd;
  border-radius: 40rpx;
  margin: 0 15rpx;
}
.btn.primary {
  color: #fff;
  background-color: #ff2d4a;
  border-color: #ff2d4a;
}
</style>